package ldh.im.fxbase.data.pojo;

import ldh.im.fxbase.cache.SoftId;
import ldh.im.fxbase.data.pojo.status.ImSexEnum;
import ldh.im.fxbase.data.pojo.status.ImUserStatus;

import java.util.Date;
import java.util.Objects;
import java.util.Set;

public class ImUser implements SoftId, Cloneable {

    private Long id;
    private String userId;
    private String userName;
    private String mobile;
    private String motto;   // 格言
    private String headImg;
    private String description;  // 自我介绍
    private String departmentCode;
    private String otherDepartmentCodes;
    private ImUserStatus status;
    private ImSexEnum sex;
    private String ext1;
    private String ext2;
    private String firstLetter;
    private Date createTime;
    private Date updateTime;

    private volatile Set<String> otherDepartmentCodeSet;

    public ImUser() {
        this.createTime = new Date();
        this.updateTime = this.createTime;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
    }

    @Override
    public String getSoftId() {
        return userName;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public ImUserStatus getStatus() {
        return status;
    }

    public void setStatus(ImUserStatus status) {
        this.status = status;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getDepartmentCode() {
        return departmentCode;
    }

    public void setDepartmentCode(String departmentCode) {
        this.departmentCode = departmentCode;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getExt1() {
        return ext1;
    }

    public void setExt1(String ext1) {
        this.ext1 = ext1;
    }

    public String getExt2() {
        return ext2;
    }

    public void setExt2(String ext2) {
        this.ext2 = ext2;
    }

    public ImSexEnum getSex() {
        return sex;
    }

    public void setSex(ImSexEnum sex) {
        this.sex = sex;
    }

    public String getMotto() {
        return motto;
    }

    public void setMotto(String motto) {
        this.motto = motto;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Set<String> getOtherDepartmentCodeSet() {
        return otherDepartmentCodeSet;
    }

    public void setOtherDepartmentCodeSet(Set<String> otherDepartmentCodeSet) {
        this.otherDepartmentCodeSet = otherDepartmentCodeSet;
    }

    public String getOtherDepartmentCodes() {
        return otherDepartmentCodes;
    }

    public void setOtherDepartmentCodes(String otherDepartmentCodes) {
        this.otherDepartmentCodes = otherDepartmentCodes;
    }

    public String getFirstLetter() {
        return firstLetter;
    }

    public void setFirstLetter(String firstLetter) {
        this.firstLetter = firstLetter;
    }

    public ImUser clone() {
        try {
            return (ImUser) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (!(obj instanceof ImUser)) return false;
        ImUser imUser = (ImUser) obj;
        if (imUser.getUserId() != null && this.getUserId() != null) {
            return imUser.getUserId().equals(this.getUserId());
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(getUserId());
    }
}
